package com.baoteng.network.executor;

import android.util.ArrayMap;

import com.baoteng.network.BuildConfig;

import java.util.Map;

/**
 * Author: loren
 * Date: 2019/8/14
 * <p>
 * 公共参数
 * 注意：全局单例，请勿随意put非公共参数
 */
public class CommonParams {

    private static volatile CommonParams instance;
    private Map<String, Object> params = new ArrayMap<>();

    public static CommonParams getInstance() {
        if (instance == null) {
            synchronized (CommonParams.class) {
                instance = new CommonParams();
            }
        }
        return instance;
    }

    public void init() {
        if (params == null) {
            params = new ArrayMap<>();
        }
        params.clear();
//        params.put("versionCode", BuildConfig.VERSION_CODE);
//        params.put("versionName", BuildConfig.VERSION_NAME);
        //..

    }

    public void putParam(String key, Object value) {
        params.put(key, value);
    }


    public void putAllParams(Map<String, String> addParams) {
        params.putAll(addParams);
    }

    public void remove(String key) {
        params.remove(key);
    }

    public void clearParams() {
        params.clear();
    }

    public Map<String, Object> getCommonParams() {
        return this.params;
    }

}
